package collection.ListTest;

/**
 * @author lcx
 * 通过异步方法判断list是否为可以成环
 */
public class JudgeList {

	public static boolean judgeList(Node root)
	{
		Node fast=root;
		Node slow=root;
		while(fast!=null&&fast.next!=null&&slow!=null)
		{
			fast=fast.next.next;
			slow=slow.next;
			if(fast==slow)
				return true;
		}
		return false;
	}
	
	public static void main(String[] args) {
		Node root=new Node(1);
		SingleList list=new SingleList(root);
		list.initSample();
		FormCircleTest.formCircleList(root);
		System.out.println(judgeList(root));
	}
}
